<template>
  <div>
    <div class="grid-content bg-purple-light">
      <div class="content content2">
        <div class="header">
          <div class="title">
            销售统计
            <span class="time">{{ $store.getters.startTime }} ~ {{ $store.getters.endTime }}</span>
          </div>
        </div>
        <div class="body">
          <div class="stats ">
            <div class="num color2">{{ orderCout }}</div>
            <div class="text color3">订单量（个）</div>
          </div>
          <div class="stats">
            <div class="num color2">{{ orderAmount }}</div>
            <div class="text color3">销售额（万元）</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { orderCout, orderAmount } from '@/api'
export default {
  props: {
    // eslint-disable-next-line vue/require-default-prop
    startTime: {
      type: String
    },
    // eslint-disable-next-line vue/require-default-prop
    endTime: {
      type: String
    }
  },
  data() {
    return {
      orderCout: 0,
      orderAmount: 0
    }
  },
  async created() {
    const res = await orderCout({
      start: `${this.$store.getters.startTime} 00:00:00`,
      end: `${this.$store.getters.endTime} 23:59:59`
    })
    const res1 = await orderAmount({
      start: `${this.$store.getters.startTime} 00:00:00`,
      end: `${this.$store.getters.endTime} 23:59:59`
    })
    this.orderCout = res.data
    this.orderAmount = (res1.data / 1000000).toFixed(2)
  }
}
</script>

<style lang="scss" scoped>
@import "~@/styles/count.scss";
.content2{
  background: #fbefe8 url(http://likede2-admin.itheima.net/img/sale.606b0d8c.png) no-repeat calc(100% - 12px) 100%;
}
.color2{
  color: #ff5757 !important;
  text-shadow: 2px 4px 7px rgb(255 99 85 / 50%) !important;
}
.color3{
  color: #de9690 !important;
}
</style>
